<div class="admin_nrtop">
    <div class="ad_search" style="font-size: 24px;">
        <?php echo $this->parentItem?"<a href='/admini/navigation/index/parentId/".$this->parentItem->ParentId."' class='indexa'>".$this->parentItem->Name."</a>下级导航展示":"第一级导航展示";?>
    </div>
</div>
<div  class="biaoge">
    <div class="biaotbody">
        <table>
            <tr>
                <th class="li3">
                    <div class="lileft">&nbsp;</div>
                </th>
                <th class="li9">
                    <div class="lileft"><span>上一级</span></div>
                </th>
                <th class="li15">
                    <div class="lileft"><span>名称</span></div>
                </th>
                <th class="li9">
                    <div class="lileft"><span>是否显示数据</span></div>
                </th>
                <th class="li15">
                    <div class="lileft"><span>链接</span></div>
                </th>
                <th class="li7">
                    <div class="lileft"><span>类别</span></div>
                </th>
                <th class="li5">
                    <div class="lileft"><span>类型</span></div>
                </th>
                <th class="li5">
                    <div class="lileft"><span>排序</span></div>
                </th>
                <th class="li5">
                    <div class="lileft"><span>状态</span></div>
                </th>
                <th class="li7">
                    <div class="lileft">添加人</div>
                </th>
                <th class="li9">
                    <div class="lileft">创建时间</div>
                </th>
                <th class="li5">
                    <div class="lileft">操作</div>
                </th>
            </tr>
        </table>
    </div>
     <div class="table">
         <table>
             <?php foreach ($this->navigationList as $Item) { ?> 
                 <tr id="tr_<?php echo $Item->id;?>">
                     <td class="li3">&nbsp;</td>
                     <td class="li9">
                         <div class="lileft">
                             <?php echo $this->parentItem?$this->parentItem->Name:"第一级导航";?>
                         </div>
                     </td>
                     <td class="li15">
                         <div class="lileft yonghu">
                             <a href="/admini/navigation/index/parentId/<?php echo $Item->id; ?>" class="indexa"><?php echo $Item->Name;?></a>
                        </div>
                     </td>
                     <td class="li9">
                         <div class="lileft">
                             <?php echo $Item->IsNum==1?"显示":"不显示";?>
                        </div>
                     </td>
                     <td class="li15">
                         <div class="lileft">
                             <?php echo $Item->Url;?>
                        </div>
                     </td>
                     <td class="li7">
                         <div class="lileft">
                             <?php echo $Item->TypeName;?>
                        </div>
                     </td>
                     <td class="li5">
                         <div class="lileft">
                             <?php echo $Item->Sign;?>
                        </div>
                     </td>
                     <td class="li5">
                         <div class="lileft">
                             <input type="text" id="order_<?php echo $Item->Order;?>" name="order[]" value="<?php echo $Item->Order;?>" onkeyup="value=value.replace(/[^\d]/g,'')" onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))" style="width:50px;"/>
                        </div>
                     </td>
                     <td class="li5">
                         <div class="lileft">
                             <?php echo $Item->StatusName;?>
                         </div>
                     </td>
                     <td class="li7">
                         <div class="lileft"> 
                             <?php echo $Item->Operator;?>
                         </div>
                     </td>
                     <td class="li9">
                         <div class="lileft">
                             <?php echo $Item->DateCreated;?>
                         </div>
                     </td>
                     <td class="li5">
                         <div class="lixlnav">
                             <a class="xlnavxq" href="javascript:void(0)" name="<?php echo $Item->Id;?>">编辑</a>
                             <div class="xlnavlistbox">
                                 <a class="xlnavsj" href="javascript:void(0);"><i></i></a>
                                 <div class="xlnavlist" style="display:none;">
                                     <ul>
                                        <li><a href="javascript:void(0)" name="<?php echo $Item->Id;?>" class="del_navigation" >回收站</a></li>
                                     </ul>
                                 </div>
                             </div>
                         </div>
                     </td>
                 </tr>
             <?php }  if(!$this->navigationList){
                echo "<font size='4' color='red'>暂无数据</font>";
                }?>   
         </table>
     </div>
 </div>
<div class="toolbar">
    <div class="qunx">
        <ul>
            <li><a class="anvbotton" href="javascript:void(0)" id="addNavigation" name="addNavigation"><span>添加导航</span></a></li>
            <li><a class="anvbotton" href="javascript:void(0)" id="editOrder" name="editOrder"><span>排序</span></a></li>
        </ul>
    </div>
<?php
    echo $this->partial('paging.phtml', array("pages" => $this->navigationAll,"pamas"=>""));        
?>
</div>
<style>
    #add_table{
        width: 600px;
        font-size: 16px;
        padding: 5px;
    }
    #add_table *{
        font-size: 14px;
        padding: 5px;
    }
</style>
<div class="tanchuang" style="display:none;">
    <div class="nui-msgbox">
        <div class="nui-msgbox-hd" id="wayProblem">添加导航</div>
        <a class="nui-msgbox-close" title="关闭"><b></b></a>
    </div>
    <div class="wenti_box" id="problemComm">
            <div style="margin-left:10px;margin-top: 15px;margin-bottom: 5px;">
                <table id="add_table">
                    <tr>
                        <td align="center" colspan="4" style="font-size:18px"><?php echo $this->parentItem?"添加".$this->parentItem->Name."的下级导航":"添加一级导航";?></td>
                    </tr>
                    <tr>
                        <td align="right">导航名称：</td>
                        <td><input type="text" id="name" name="name" value="" /></td>
                        <td align="right">显示数据：</td>
                        <td><select id="isNum" name="isNum">
                                <option value="1">显示</option>
                                <option value="0">不显示</option>
                            </select></td>
                    </tr>
                    <tr>
                        <td align="right">导航链接：</td>
                        <td colspan="3"><input type="text" id="url" name="url" value="" style="width:300px;"/></td>
                    </tr>
                    <tr>
                        <td align="right">类型：</td>
                        <td><input type="text" id="sign" name="sign" value="" /></td>
                        <td align="right">排序：</td>
                        <td><input type="text" id="order" name="order" value="" /></td>
                    </tr>
                    <tr>
                        <td align="right">状态：</td>
                        <td><select id="status" name="status">
                                <?php foreach ($this->statusAll as $key => $statusVal){?>
                                <option value="<?php echo $key;?>"><?php echo $statusVal;?></option>
                                <?php } ?>
                            </select></td>
                        <td align="right">类别：</td>
                        <td><select id="type" name="type">
                                <?php foreach ($this->typeAll as $key=> $typeVal) { ?>
                                <option value="<?php echo $key;?>"><?php echo $typeVal;?></option>
                                <?php } ?>
                            </select></td>
                    </tr>
                    <tr>
                        <td align="center"  colspan="4">
                            <input type="hidden" id="parentId" name="parentId" value="<?php echo $this->parentId;?>" />
                            <input type="hidden" id="navigationId" name="navigationId" value="0" />
                            <input type="button" id="navigationAdd" naem="navigationAdd" value="添加" style="background-color: #F60;width: 50px;height: 36px;color: white;font-size: 16px;border-radius:8px;"/>
                            &nbsp;&nbsp;<input type="button" id="refo" naem="refo" value="返回" style="background-color: #1668A4;width: 50px;height: 36px;color: white;font-size: 16px;border-radius:8px;"/>
                        </td>
                    </tr>
                </table>
            </div>
    </div>
</div>
<div class="houtai_overlay" style="display:none;"></div>
<script>
    $(".xlnavsj").live("mousemove",function(){
        $(this).next("div").show();
    });
    $(".lixlnav").mouseleave(function(){
        $(".xlnavsj").next("div").hide();
    });
    $("#addNavigation").click(function(){
        $(".houtai_overlay").show();
        $(".tanchuang").show();
    });
    $(".nui-msgbox-close").click(function(){
        $(".houtai_overlay").hide();
        $(".tanchuang").hide();
    })
    $(".xlnavxq").click(function(){
       var id = $(this).attr("name");
       $.post("/admini/navigation/navigationdetail",{"id":id},function(date){
           if(date.sj == 1){
                $("#name").val(date.name);
                $("#url").val(date.url);
                $("#sign").val(date.sign);
                $("#order").val(date.order);
                $("#type").find("option[value='"+date.type+"']").attr("selected",true);
                $("#status").find("option[value='"+date.status+"']").attr("selected",true);
                $("#isNum").find("option[value='"+date.isNum+"']").attr("selected",true);
                $("#parentId").val(date.parentId);
                $("#navigationId").val(id);
                $("#navigationAdd").val("修改");
                $(".houtai_overlay").show();
                $(".tanchuang").show();
           }else{
               alert("出现未知错误，请刷新在试。");
           }
       });
    });
    $(".del_navigation").click(function(){
        if(confirm("您确认删除该导航及其下级所有导航？","提示信息")){ 
            var id = $(this).attr("name");
            $.post("/admini/navigation/delnavigation",{"id":id},function(date){
               if(date.sj == 1){
                    alert("删除成功");
                    $("#tr_"+id).remove();
               }else{
                   alert("出现未知错误，请刷新在试。");
               }
           },"json");
        }
    });
    $("#refo").click(function(){
        $(".houtai_overlay").hide();
        $(".tanchuang").hide();
    });
    $("#navigationAdd").click(function(){
        var id = $("#navigationId").val();
        var name = $("#name").val();
        var isNum = $("#isNum").val();
        var url = $("#url").val();
        var sign = $("#sign").val();
        var order = $("#order").val();
        var type = $("#type").val();
        var status = $("#status").val();
        var parentId = $("#parentId").val();
        if(name == ""){
            alert("导航名称不能为空");
            return ;
        }
        if(url == ""){
            alert("链接地址不能为空");
            return ;
        }
        if(sign == ""){
            alert("导航类型不能为空");
            return ;
        }
        if(order == ""){
            alert("导航排序不能为空");
            return ;
        }
        $.post('/admini/navigation/addnavigation', {'id':id,'parentId':parentId,'name':name,"isNum":isNum,'url':url,"sign":sign,"order":order,"type":type,"status":status}, function(sj){
             if(sj == 1){
                 alert("添加成功！");
                 location.href = "/admini/navigation/index/parentId/"+parentId;
             }else{
                 alert("出现未知错误");
             }
        }, 'json');
       
    });
    $("#editOrder").click(function(){
        var orderAll = "";
        var parentId = $("#parentId").val();
        var isOrder = false;
        $.each($("input[name='order[]']"), function(i,val){ 
            if(val.value == ""){
                alert("排序值不能为空");
                isOrder = true;
                return ;
            }
            orderAll += val.value+",";   
        });
        if(isOrder){
            return ;
        }
        $.post("/admini/navigation/ordernavigation",{"parentId":parentId,"orderAll":orderAll},function(date){
            if(date == 1){
                 alert("设置成功");
                 location.href = "/admini/navigation/index/parentId/"+parentId;
            }else{
                alert("出现未知错误，请刷新在试。");
            }
        },"json");
    });
</script>